package cn.wolfcode.mq;

import cn.wolfcode.service.IOrderInfoService;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author zhenfeng
 * @Date 2021/5/17
 *
 * 订单超时未支付消费者
 */
@Component
@RocketMQMessageListener(
        consumerGroup = "MQSeckillTimeoutCustomer",
        topic = MQConstant.ORDER_PAY_TIMEOUT_TOPIC
)
@Slf4j
public class MQSeckillTimeoutCustomer implements RocketMQListener<OrderMQResult> {

    @Autowired
    private IOrderInfoService orderInfoService;

    @Override
    public void onMessage(OrderMQResult orderMQResult) {
        log.info("进入超时未支付队列...");
        orderInfoService.seckillOrderTimeout(orderMQResult);
    }
}
